home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_084 / ed / getfn.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  857b  |  54 lines

  1. /*
  2.  * Copyright 1987 Brian Beattie Rights Reserved.
  3.  *
  4.  * Permission to copy and/or distribute granted under the
  5.  * following conditions:
  6.  *
  7.  * 1). No charge may be made other than resonable charges
  8.  *    for reproduction.
  9.  *
  10.  * 2). This notice must remain intact.
  11.  *
  12.  * 3). No further restrictions may be added.
  13.  *
  14.  */
  15. #include <stdio.h>
  16. #include "tools.h"
  17. #include "ed.h"
  18.  
  19. extern char    fname[MAXFNAME];
  20. char    *
  21. getfn()
  22. {
  23.     static char    file[256];
  24.     char    *cp;
  25.  
  26.     if(*inptr == NL)
  27.     {
  28.         strcpy(file, fname);
  29.     } else {
  30.         while(*inptr == SP || *inptr == HT)
  31.             inptr++;
  32.  
  33.         cp = file;
  34.         while(*inptr && *inptr != NL && *inptr != SP && *inptr != HT)
  35.         {
  36.             *cp++ = *inptr++;
  37.         }
  38.         *cp = '\0';
  39.  
  40.         if(strlen(file) == 0)
  41.         {
  42.             printf("bad file name\n");
  43.             return( NULL );
  44.         }
  45.     }
  46.  
  47.     if(strlen(file) == 0)
  48.     {
  49.         printf("no file name\n");
  50.         return(NULL);
  51.     }
  52.     return( file );
  53. }
  54.